//
//  UILabel+Extension.swift
//  E-CycleForShop
//
//  Created by enghou on 17/3/10.
//  Copyright © 2017年 xyxorigation. All rights reserved.
//

import UIKit
extension UILabel{
    func configLineSpacing(space : CGFloat) -> Void {
        guard self.attributedText != nil else {
            return
        }
        let attributedStr = NSMutableAttributedString.init(attributedString: self.attributedText!)
        let paragraphStyle = NSMutableParagraphStyle.init()
        paragraphStyle.lineSpacing = space
        attributedStr.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, self.attributedText!.length))
        let heiTmp = "我".StringSize(font: self.font).height
        let size = self.text!.stringSize(font: self.font, maxWid: YXDeviceWidth - 120 * YXWidthScale)
        let numberOfLine = size.height / heiTmp
        self.numberOfLines = Int(numberOfLine)
        let sizeFinal = CGSize.init(width: size.width, height: size.height + (numberOfLine - 1.0) * space)
        self.attributedText = attributedStr
        self.frame = CGRect.init(origin: self.frame.origin, size: sizeFinal)
    }
}
